use ggez::{glam::Vec2, Context};

pub struct Physics {
    pub location: Vec2,
    pub velocity: Vec2,
    pub topspeed: f32,
    pub acceleration: Vec2
}

impl Physics {
    pub fn check_edges(&mut self, ctx: &mut Context) -> () {
        if self.location.x > ctx.gfx.window().inner_size().width as f32 {
            self.location.x = ctx.gfx.window().inner_size().width as f32;
            self.velocity.x = -self.velocity.x;
        }
        else if self.location.x < 0.0 {
            self.location.x = 0.0;
            self.velocity.x = -self.velocity.x;
        }
    
        if self.location.y > ctx.gfx.window().inner_size().height as f32 {
            self.location.y = ctx.gfx.window().inner_size().height as f32;
            self.velocity.y = -self.velocity.y;
        }
        else if self.location.y < 0.0 {
            self.location.y = 0.0;
            self.velocity.y = -self.velocity.y;
        }
    }
}